# -*- coding: utf-8 -*-
"""
@Time    : 2024/6/21 12:52 
@Author  : ZhangShenao 
@File    : app1.py
@Desc    : Http服务启动入口
"""
import dotenv
from flask_migrate import Migrate
from injector import Injector

from config import Config
from extension_module import ExtensionModule
from internal.router import Router
from internal.server import HttpServer
from pkg.sqlalchemy import SQLAlchemy

# 读取.env配置,并加载到环境变量中,实现配置文件与代码解耦
dotenv.load_dotenv()

# 创建应用配置
conf = Config()

# 创建依赖注入器
injector = Injector([ExtensionModule])

# 创建Http服务
http_server = HttpServer(__name__,
                         conf=conf,
                         db=injector.get(SQLAlchemy),
                         migrate=injector.get(Migrate),
                         router=injector.get(Router))

# 启动Http服务
if __name__ == '__main__':
    http_server.run(debug=True, port=8080)
